define(['app'],function(app){
    return {module: function($scope, $http, eventBusService, httpService, params, configService) {


            //学年学期
            httpService.post(app.urls.prop_select,{},function(data){
                if("0000" === data.code){
                    $scope.propList = data.data;
                }else{
                    alert(data.msg);
                }
            });
            //年级
            httpService.post(app.urls.grade_select,{fk_stage:"02030218-1e1c-4dc8-81f5-10e0ceb015a4"},function(data){
                if("0000" === data.code){
                    $scope.gradeList = data.data;
                }else{
                    alert(data.msg);
                }
            });


            $scope.find=function () {
                httpService.post(app.urls.leave_task_selectById,{id:params.id}, function(data) {
                    if("0000" === data.code) {
                        $scope.form=data.data[0];
                    } else {
                        eventBusService.publish("modal.alert", {"content": data.msg});
                    }
                });
            }
            $scope.find();


            $scope.save=function () {
                if($scope.formCheck()){

                    httpService.post(app.urls.leave_task_update,$scope.form,function(data) {
                        if ("0000" === data.code) {
                            eventBusService.publish("modal.alert", {"content": "修改成功"});
                            eventBusService.publish("content.page.reload", data.data);
                            eventBusService.publish("modal.page.close", {});
                        }else {
                            alert(data.msg);
                        }
                    });
                }
            }


        }
    }});